<?php echo HTML::script('plugins/codeprettifier/prettify.css');?>
<?php echo HTML::script('plugins/form-toggle/toggles.css');?>
<?php echo HTML::plugins('form-select2/select2.css');?>
<?php echo(HTML::script('plugins/form-validation/jquery.validate.min.js'));?>
<?php echo(HTML::script('plugins/form-stepy/jquery.stepy.js'));?>
<?php echo(HTML::script('plugins/form-multiselect/js/jquery.multi-select.min.js'));?>
<?php echo(HTML::script('plugins/form-select2/select2.min.js'));?>
<?php echo(HTML::script('administracio.js'));?>
	<div id="page-heading">
      <ol class="breadcrumb">
        <li><a href="<?php echo(url(''));?>">Portada</a></li>
        <li>Administració</li>
        <li class="active">Crear Usuari</li>
      </ol>
    </div>
	<div class="container">
		<div class="row">
			<div class="col-md-12">

				<div class="panel panel-info">
					<div class="panel-heading">
						<h4><?php echo(Lang::get('usuarios.crear_usuario'));?></h4>
					</div>
					<div class="panel-body">
					
						<form action="javascript:form_crear_usuario();" id="form_crear_usuario" class="form-horizontal">

							<fieldset title="Paso 1">
								<legend>Dades usuari</legend>
								<div class="form-group">
									<label for="fieldname" class="col-md-3 control-label"><?php echo(Lang::get('usuarios.nombre_usuario'));?></label>
									<div class="col-md-6">
										<input id="nom_usuari" class="form-control" minlength="4" type="text">
									</div>
								</div>
								<div class="form-group">
									<label for="fieldname" class="col-md-3 control-label"><?php echo(Lang::get('usuarios.usuario'));?></label>
									<div class="col-md-6">
										<input id="usuari" class="form-control" minlength="4" type="text">
									</div>
									<!-- required -->
								</div>
								<div class="form-group">
									<label for="fieldname" class="col-md-3 control-label"><?php echo(Lang::get('usuarios.contrasenya'));?></label>
									<div class="col-md-6">
										<input id="contrasenya" class="form-control" minlength="5" type="password">
									</div>
								</div>
								<div class="form-group" id="repetir_contrasenya" style="display: none">
									<label for="fieldname" class="col-md-3 control-label"><?php echo(Lang::get('usuarios.repetir_contrasenya'));?></label>
									<div class="col-md-6">
										<input id="contrasenya2" class="form-control" minlength="5" type="password">
									</div>
								</div>
								<div class="form-group">
									<label for="fieldemail" class="col-md-3 control-label"><?php echo(Lang::get('usuarios.email'));?></label>
									<div class="col-md-6">
										<input id="email" class="form-control" type="email">
									</div>
								</div>
								<div class="form-group" id="repetir_email" style="display: none">
									<label for="fieldemail" class="col-md-3 control-label"><?php echo(Lang::get('usuarios.repetir_email'));?></label>
									<div class="col-md-6">
										<input id="email2" class="form-control" type="email">
									</div>
								</div>

							</fieldset>

							<fieldset title="Paso 2">
								<legend>Permisos</legend>
								<div class="col-md-12">
									<div class="form-group">
										<label class="col-sm-2 control-label">Tipus usuari</label>
										<div class="col-sm-3">
											<select id="rol" style="width:100%" class="populate">
												<optgroup label="Tipus usuari">
													<?php foreach($info['permisos'] as $permiso){?>
														<option value="<?php echo($permiso->id);?>"><?php echo($permiso->tipo);?></option>
													<?php }?>
												</optgroup>
											</select>
										</div>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">Gestor defecte</label>
									<div class="col-sm-3">
										<select id="lista_permisos_usuari" style="width:100%" class="populate">
											<optgroup label="Gestor">
												<?php foreach($info['gestores'] as $gestor){?>
													<option value="<?php echo($gestor->id);?>"><?php echo($gestor->nombre);?></option>
												<?php }?>
											</optgroup>
										</select>
									</div>
									<label class="col-sm-2 control-label">Permis gestor defecte</label>
									<div class="col-sm-3">
										<select id="permiso_gestor_defecto" style="width:100%" class="populate">
											<optgroup label="Permis">
												<?php $permisos = array_reverse($info['permisos']); foreach($permisos as $permiso){?>
													<option value="<?php echo($permiso->id);?>"><?php echo($permiso->tipo);?></option>
												<?php }?>
											</optgroup>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">Més Gestors</label>
									<div class="col-sm-8">
										<select id="listado_gestores_usuario" multiple style="width: 100%" class="populate">
											<optgroup label="Gestors">
											<?php foreach($info['mes_gestors'] as $gestor){?>
													<option value="<?php echo($gestor->valor);?>"><?php echo($gestor->nombre);?></option>
											<?php } ?>
											</optgroup>
										</select>
									</div>
								</div>
							</fieldset>
							<input type="submit" class="finish btn-success btn " value="Submit" />
						</form>
					</div>
				</div>
			</div>
		</div>
</div>
<script type="text/javascript">

crear_usuario();

</script>
